package study.rabbitmq.consumer;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import study.rabbitmq.consumer.config.RabbitConfig;

/**
 * 监听广播消息
 */
@Component
public class ConsumerMsg {

    @RabbitListener(queues = RabbitConfig.ALL_QUEUE) // 可以放到类上，边上这个类处理这个队列
    public void receiveAllFirstMsg(String msg) {
        System.out.println(this.getClass().getSimpleName()+msg);
    }

    @RabbitListener(queues = RabbitConfig.ALL_SENCOND_QUEUE)
    public void receiveAllSencondMsg(String msg) {
        System.out.println(this.getClass().getSimpleName()+msg);
    }

    @RabbitListener(queues = RabbitConfig.PRIVATE_CHART_QUEUE)
    public void receivePrivateChart(String msg) {
        System.out.println(this.getClass().getSimpleName()+msg);
    }

    @RabbitListener(queues = RabbitConfig.SUBCRIBE_QUEUE)
    public void receivePubMsg(String msg) {
        System.out.println(this.getClass().getSimpleName()+msg);
    }

    @RabbitListener(queues = RabbitConfig.TTL_QUEUE)
    public void ttlMsg(String msg) {
        System.out.println(this.getClass().getSimpleName()+"ttl:"+msg);
    }

}
